package com.td.client.gui;

import org.newdawn.slick.Graphics;

import com.td.client.log.GameplayInfo;
import com.td.core.communication.obj.PreGameInfo;
import com.td.core.obj.TDGame;

public class GameRenderer {
	
	private static GameRenderer renderer = null;
	
	private TDGame game; 
	
	private PreGameInfo preGameInfo; //potrzebne do wyswietlania wynikow graczy
	private GameplayInfo gameplayInfo;
	
	private int baseX;
	private int baseY;
	
	private GameRenderer(TDGame game, PreGameInfo preGameInfo, GameplayInfo gameplayInfo) {
		this.game = game;
		this.preGameInfo = preGameInfo;
		this.gameplayInfo = gameplayInfo;
	}
	
	public static GameRenderer createInstance(
			TDGame game, PreGameInfo preGameInfo, GameplayInfo gameplayInfo) {
		renderer = new GameRenderer(game, preGameInfo, gameplayInfo);
		return renderer;
	}
	
	public static GameRenderer getInstance() {
		return renderer;
	}
	
	public int getBaseX() {
		return baseX;
	}

	public void setBaseX(int baseX) {
		this.baseX = baseX;
	}

	public int getBaseY() {
		return baseY;
	}

	public void setBaseY(int baseY) {
		this.baseY = baseY;
	}

	public void draw(Graphics g) {
		MapRenderer.getInstance().draw(g);
		
		AdditivesRenderer.draw(gameplayInfo, preGameInfo, g);
		
		for(int i = 0; i < game.getPlayers().length; i++) {
			PlayerRenderer.draw(i, game.getPlayers()[i], g);
		}
	}
}